package cn.edu.gzmtu.service.impl;

import cn.edu.gzmtu.dao.IOrdersDao;
import cn.edu.gzmtu.domain.Orders;
import cn.edu.gzmtu.service.IOrdersService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("ordersService")
@Transactional
public class OrdersServiceImpl implements IOrdersService {

    @Autowired
    private IOrdersDao ordersDao;

    /**
     * 查询所有订单
     *
     * @return
     * @throws Exception
     */
    @Override
    public List<Orders> findAll() throws Exception {

        return ordersDao.findAll();
    }

    /**
     * 查询所有订单
     * 带分页查询
     *
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public List<Orders> findAll(Integer pageNum, Integer pageSize) throws Exception {

        // 设置分页查询：pageNum:要查询的页码，pageSize:每页的记录数
        PageHelper.startPage(pageNum, pageSize);
        return ordersDao.findAll();
    }

    /**
     * 根据id查询订单详情
     *
     * @param id
     * @return
     */
    @Override
    public Orders findById(String id) throws Exception {

        return ordersDao.findById(id);
    }
}
